/**
 * 
 */
package orion.jarvis.task.event;

import java.util.ArrayList;
import java.util.List;



/**
 * @author Ted
 * 
 */
public class EventListenerQueue{
	public List<EventListener> listeners = new ArrayList<EventListener>();

	public void register(EventListener listener) {
		listeners.add(listener);
	}

	public void perform(TaskEvent event) {
		for (EventListener listener : listeners) {
			if (listener.interested(event.getCategory()))
				listener.perform(event);
		}
	}

	public EventListener[] getRegistedListeners() {
		return listeners != null ? (listeners.size() > 0 ? listeners.toArray(new EventListener[] {}) : new EventListener[] {})
				: new EventListener[] {};
	}

}
